﻿using CompactMapper.Orm.Contracts;

namespace CompactMapper.Orm.Tests
{
    internal class MusicDatabasePopulation
    {
        internal const string ArtistName = "Depeche Mode";
        internal const string SongName = "Everything Counts";
        internal const string RecordName1 = "Construction Time Again";
        internal const string RecordName2 = "101";
        internal const string Label1 = "interscope";
        internal const string Label2 = "mute";
        internal const string Publisher = "EMI";
        internal static readonly Artist Artist;


        static MusicDatabasePopulation()
        {
            Artist = new Artist
            {
                ArtistName = ArtistName
            };
            Artist.AddTrack(new Track { TrackName = SongName, Publisher = new Publisher { Name = Publisher } });
            var record = new Record { RecordName = RecordName1, Publisher = new Publisher { Name = Publisher } };
            record.AddTrack(new Track { TrackName = SongName, Publisher = new Publisher { Name = Publisher } });
            Artist.AddRecord(record);
            
            record = new Record { RecordName = RecordName2, Publisher = new Publisher { Name = Publisher } };
            record.AddTrack(new Track { TrackName = SongName, Publisher = new Publisher { Name = Publisher } });
            Artist.AddRecord(record);
        }


        internal static void Populate(IKeyedSqLiteUnitOfWork<Artist> artistUnitOfWork)
        {
            artistUnitOfWork.MakePersistent(Artist);
            artistUnitOfWork.PersistAll();
        }
        internal static void Populate(IKeyedSqLiteUnitOfWork<Label> labelUnitOfWork)
        {
            labelUnitOfWork.MakePersistent(new Label { Name = Label1 });
            labelUnitOfWork.MakePersistent(new Label { Name = Label2 });
            labelUnitOfWork.PersistAll();
        }
    }
}
